package com.yang.o2o.util;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;

public class CodeUtil {
    /**
     * 判断验证码
     * */
    public static boolean checkVerifyCode(HttpServletRequest request){
        String verifyCodeExpected = (String) request.getSession().getAttribute(
                Constants.KAPTCHA_SESSION_KEY);  //实际的验证码
        String verifyCodeActual = HttpServletRequestUtil.getString(request,"verifyCodeActual"); //输入的

        if(!verifyCodeActual.equals(verifyCodeExpected) || verifyCodeActual == null){
            return false;
        }
        else{
            return true;
        }
    }
}
